package com.agentlab.imitation.web.action;


import java.io.ByteArrayInputStream;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;

import com.agentlab.imitation.common.CommonConstant;
import com.agentlab.imitation.util.RandomNumUtil;
import com.opensymphony.xwork2.ActionContext;


@Controller 
public class RandomPictureActon  {
	private ByteArrayInputStream inputStream;
	/**
	 * 取随机图片
	 */
	//public String execute() throws Exception{  
	public String random(){
        RandomNumUtil rdnu =  RandomNumUtil.Instance(4,true); 
        //取得带有随机字符串的图片
        this.setInputStream(rdnu.getImage());
        //取得随机字符串放入HttpSession
        ActionContext.getContext().getSession().put(CommonConstant.RANDOM_SESSION, rdnu.getString());
        return "success";
	}
	

	public ByteArrayInputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(ByteArrayInputStream inputStream) {
		this.inputStream = inputStream;
	}
}
